//
//  DeviceUtil.m
//  Staff
//
//  Created by caiyao on 8/6/15.
//
//

#import "DeviceUtil.h"

@implementation DeviceUtil

+ (UIDeviceResolution) currentResolution
{
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
        {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            result = CGSizeMake(result.width * [UIScreen mainScreen].scale, result.height * [UIScreen mainScreen].scale);
            
            if (result.height <= 480.0f)
            {
                return UIDevice_iPhoneStandardRes;
            }
            
            // Modified by Joe [4 May.2015]. For supporting iPhone6/6+
            // return (result.height > 960 ? UIDevice_iPhoneTallerHiRes : UIDevice_iPhoneHiRes);
            else if (result.height <= 960.0f) {
                
                return UIDevice_iPhoneHiRes;
            }
            else if (result.height <= 1136.0) {
                
                return UIDevice_iPhoneTallerHiRes;
            }
            else if (result.height <= 1334.0) {
                
                return UIDevice_iPhone6Res;
            }
            else if (result.height <= 2001.0) {
                
                return UIDevice_iPhone6Res;
            }
            else {
                
                return UIDevice_iPhone6PlusRes;
            }
            // End by Joe [4 May.2015]
        }
        else
        {
            return UIDevice_iPhoneStandardRes;
        }
    }
    
    return (([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) ? UIDevice_iPadHiRes : UIDevice_iPadStandardRes);
}

@end
